'''
* This is the projet for Brtc LlmOps Platform
* @Author Leon-liao <liaosiliang@alltman.com>
* @Description //TODO 
* @File: 3_study_configurable_field.py
* @Time: 2025/10/24
* @All Rights Reserve By Brtc
'''
import dotenv
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.runnables import ConfigurableField
from langchain_openai import ChatOpenAI

dotenv.load_dotenv()
#1、创建提示词
prompt = ChatPromptTemplate.from_template("{query}")
llm = ChatOpenAI(model="gpt-4o-mini").configurable_alternatives(
    ConfigurableField(id="llm"),
    gpt4=ChatOpenAI(model="gpt-4o-6666"),
    gpt5=ChatOpenAI(model="gpt-5")
)

#2、构建一个链
chain = prompt|llm|StrOutputParser()

content = chain.invoke(
    {"query":"你好,你是Gpt几？"},
    config={"configurable":{"llm":"gpt5"}}
)
print(content)